jQuery.fn.Particles = function() {	
		var args = arguments[0] || {};    
		var delay = args.delay;
		if(!delay){delay = 0;}
	
		var number_of_particles = 45;
		var min_opacity = 0.8;
		var max_opacity = 1;
		var min_size = 4;
		var max_size = 30;
		var min_moving_speed = 10000;
		var max_moving_speed = 20000;		
		var max_top = 350;
		
				
		var this_div = $(this);		
		
		//if IE8 or lower, use PNG-8 particle images
		var ie_fix = '';
		if(jQuery.browser.msie && jQuery.browser.version < 9){
			ie_fix = '-ie';
		}
		//ie_fix = ''; //Fixed EdazCommerce
		
		//place particles function
		function addParticles(i){	
			var random_size = randomXToY(min_size,max_size);
				if(random_size > 8){
					var random_opacity = randomXToY(min_opacity,0.2,1);
				}else{
					var random_opacity = randomXToY(0.7,max_opacity,1);
				}						
			var random_v_position = randomXToY(50,max_top);
			var random_moving_speed = randomXToY(min_moving_speed,max_moving_speed);
			
			var random_starting_position_l = randomXToY(90,490);		
			var random_starting_position_r = randomXToY(490,880);		
			var random_delay_fadeout = randomXToY(3000,6000);		
			
			if( random_v_position > 450 ){
				var random_v_direction_name = 'bottom';
			}else{
				var random_v_direction_name = 'top';
			}
			
			this_div.append('<img src="images/particle'+ie_fix+'.png" id="particle-'+i+'" class="all_particles" />');
			
			if(random_v_direction_name == 'top'){
				$('#particle-'+i).css({
					'position':'absolute',
					'width':random_size+'px',
					'height':random_size+'px',					
					'top':random_v_position+'px',
					opacity:0
				});				
			}else{
				$('#particle-'+i).css({
					'position':'absolute',
					'width':random_size+'px',
					'height':random_size+'px',					
					'bottom':random_v_position+'px',				
					opacity:0
				});
			}
			
			$('#particle-'+i).delay(delay).animate({opacity:random_opacity},{duration: 1100});
			
			
			//set movement to the left and to the right
			var aniArgs = {};			
			
			if(i > (number_of_particles / 2)){	
				aniArgs['left'] = '1080px';			
				aniArgs[random_v_direction_name] = (random_v_position + 200) + 'px';											
				
				//set random position
				$('#particle-'+i).css('left',random_starting_position_r + 'px');
				
				
			}else{
				aniArgs['left'] = '-100px';				
				aniArgs[random_v_direction_name] = (random_v_position + 200) + 'px';		

				//set random left/right pos padding
				$('#particle-'+i).css('left',random_starting_position_l + 'px');				
				
			}
					
			//start animation of particles
			var this_i = i;
			$('#particle-'+i).animate(aniArgs,{
				queue: false,
				duration: random_moving_speed,
				easing: 'linear'
			}).delay(random_delay_fadeout).fadeOut(500,function(){
				//anim complete								
					
					//remove particle img									
					$(this).remove();
					
					//LOOP: add new		
					addParticles(this_i);						
			});
			
		}
		
		
		//START
		var i=0;
		for(i=0;i<=number_of_particles;i++){			
			addParticles(i);
		}
		
		
		
	//function to get random number
	function randomXToY(minVal,maxVal,floatVal)
	{
	  var randVal = minVal+(Math.random()*(maxVal-minVal));
	  return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
	}
	
	
	
};